/**
 * @date 2006-7-21
 */

package org.nanhill.moo.dao.hibernate;

import org.nanhill.moo.dao.TagDao;
import org.nanhill.moo.domain.Tag;
import org.nanhill.support.hibernate.HibernateEntityManager;

/**
 * @author alin [xalinx at gmail dot com]
 * @date 2006-7-21
 */
public class TagDaoImpl extends HibernateEntityManager<Tag, Long> implements
		TagDao {

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.nanhill.moo.dao.TagDao#findByName(java.lang.String)
	 */
	public Tag findByName(String name) {
		return this.findOne("from Tag p where p.name = ?", name);
	}

	// public boolean isUserTag(final long userId, final String tagName) {
	// long findUserId = (Long) getHibernateTemplate().execute(
	// new HibernateCallback() {
	// public Object doInHibernate(Session session)
	// throws HibernateException {
	// Query q = session
	// .createQuery("select p.id from User p where p.id = ? and p.tags.name =
	// ?");
	// q.setParameter(0, userId);
	// q.setParameter(1, tagName);
	// return q.uniqueResult();
	// }
	// });
	// return findUserId > 0 ? true : false;
	// }

}
